import 'dart:convert';

OrderModel orderModelFromJson(String str) =>
    OrderModel.fromJson(json.decode(str));

String orderModelToJson(OrderModel data) => json.encode(data.toJson());

class OrderModel {
  int code;
  String? msg;
  List<OrderData>? data;

  OrderModel({
    required this.code,
    this.msg,
    this.data,
  });

  factory OrderModel.fromJson(Map<String, dynamic> json) => OrderModel(
        code: json["code"],
        msg: json["msg"],
        data: List<OrderData>.from(
            json["data"].map((x) => OrderData.fromJson(x))),
      );

  Map<String, dynamic> toJson() => {
        "code": code,
        "msg": msg,
        "data": List<dynamic>.from(data!.map((x) => x.toJson())),
      };
}

class OrderData {
  int aid;
  double amount;
  int? cid;
  String consignee;
  double? couponAmount;
  String detail;
  int id;
  String number;
  String orderTime;
  int? payMethod;
  String phone;
  String? remark;
  int status;
  int uid;
  List<OrderDetailData> orderDetailList;

  OrderData({
    required this.aid,
    required this.amount,
    this.cid,
    required this.consignee,
    this.couponAmount,
    required this.detail,
    required this.id,
    required this.number,
    required this.orderTime,
    this.payMethod,
    required this.phone,
    this.remark,
    required this.status,
    required this.uid,
    required this.orderDetailList
  });

  factory OrderData.fromJson(Map<String, dynamic> json) => OrderData(
      aid: json["aid"],
      amount: json["amount"],
      cid: json["cid"],
      consignee: json["consignee"],
      couponAmount: json["couponAmount"],
      detail: json["detail"],
      id: json["id"],
      number: json["number"],
      orderTime: json["orderTime"],
      payMethod: json["payMethod"],
      phone: json["phone"],
      remark: json["remark"],
      status: json["status"],
      orderDetailList: List<OrderDetailData>.from(json["orderDetailList"].map((x) => OrderDetailData.fromJson(x))),
      uid: json["uid"]);

  Map<String, dynamic> toJson() => {
        "aid": aid,
        "amount,": amount,
        "cid": cid,
        "consignee": consignee,
        "couponAmount": couponAmount,
        "detail": detail,
        "id": id,
        "number": number,
        "orderTime": orderTime,
        "payMethod": payMethod,
        "phone": phone,
        "remark": remark,
        "status": status,
        "uid": uid,
        "orderDetailList": List<dynamic>.from(orderDetailList.map((x) => x.toJson())),
      };
}

class OrderDetailData {
  int id;
  double amount;
  String coverUrl;
  String description;
  String ename;
  int fid;
  int inventory;
  String meaning;
  String name;
  int number;
  int oid;
  double price;
  int sales;
  String unit;
  int views;

  OrderDetailData({
    required this.id,
    required this.amount,
    required this.coverUrl,
    required this.description,
    required this.ename,
    required this.fid,
    required this.inventory,
    required this.meaning,
    required this.name,
    required this.number,
    required this.oid,
    required this.price,
    required this.sales,
    required this.unit,
    required this.views,
  });

  factory OrderDetailData.fromJson(Map<String, dynamic> json) => OrderDetailData(
      id: json["id"],
      amount: json["amount"],
      coverUrl: json["coverUrl"],
      description: json["description"],
      ename: json["ename"],
      fid: json["fid"],
      inventory: json["inventory"],
      meaning: json["meaning"],
      name: json["name"],
      number: json["number"],
      oid: json["oid"],
      price: json["price"],
      sales: json["sales"],
      unit: json["unit"],
      views: json["views"]);

  Map<String, dynamic> toJson() => {
        "id": id,
        "amount,": amount,
        "coverUrl": coverUrl,
        "description": description,
        "ename": ename,
        "fid": fid,
        "inventory": inventory,
        "meaning": meaning,
        "name": name,
        "number": number,
        "oid": oid,
        "price": price,
        "sales": sales,
        "unit": unit,
        "views": views,
      };
}



